﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;

namespace GMS
{
    public partial class Pages_Admin_Stone : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!SessionVariable.Instance.UserDetails.IsAdmin)
            {
                Response.Redirect("Login.aspx");
            }
        }

        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(txtName.Text) && !string.IsNullOrWhiteSpace(txtThumbmail.Text) &&
                !string.IsNullOrWhiteSpace(txtImage.Text) && !string.IsNullOrWhiteSpace(txtOrigin.Text) &&
                !string.IsNullOrWhiteSpace(txtThickness.Text) && !string.IsNullOrWhiteSpace(txtPrice.Text))
            {
                Common.AddStone(txtName.Text, txtDesc.Text, txtThumbmail.Text, txtImage.Text,
                    Convert.ToInt32(ddlStoneType.SelectedItem.Value), Convert.ToInt32(ddlStoneCategory.SelectedItem.Value),
                    txtOrigin.Text, txtThickness.Text, Convert.ToInt32(txtPrice.Text));
                gvStone.DataBind();

                txtName.Text = string.Empty;
                txtDesc.Text = string.Empty;
                txtThumbmail.Text = string.Empty;
                txtImage.Text = string.Empty;
                txtOrigin.Text = string.Empty;
                txtThickness.Text = string.Empty;
                txtPrice.Text = string.Empty;
            }
        }
    }
}